import { shopStatusValues } from '@/lib/db/schema/enum';
import { z } from 'zod';

export const adminShopSearchSchema = z.object({
  name: z.string().max(50, { message: '店铺名称最多50个字符' }).optional(),
  address: z.string().max(50, { message: '店铺地址最多50个字符' }).optional(),
  contactPhone: z
    .string()
    .max(20, { message: '店铺电话最多20个字符' })
    .optional(),
  dateRange: z
    .object({
      from: z.date(),
      to: z.date().optional(),
    })
    .optional(),
  id: z
    .string()
    .refine((v) => v === '' || !Number.isNaN(v), {
      message: '店铺ID必须为数字',
    })
    .refine((v) => Number(v) >= 0 && Number.isInteger(Number(v)), {
      message: '店铺ID必须为正整数',
    })
    .optional(),
  status: z.array(z.enum(shopStatusValues)).optional(),
});
